﻿Imports VN.INS.BL.BC
Imports System.Data
Imports System.IO
Imports Microsoft.Office.Interop

Partial Class Devida_Reporte_Varios
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
        If Not (Me.Page.IsPostBack) Then
            Dim objBC As New ReporteBC
            Dim objDt As New DataTable
            Dim objDt1 As New DataTable
            Dim objDt2 As New DataTable
            objDt1 = objBC.Lista_PPER()
            objDt = objBC.Lista_PPER_EJECUTOR(Session("Año"))
            objDt2 = objBC.Lista_PPER_REGION(Session("Año"))
            ViewState("Data") = objDt
            ViewState("Data2") = objDt2
            gv_PPER.DataSource = objDt1
            gv_PPER.DataBind()
            gv_Region.DataSource = objDt1
            gv_Region.DataBind()
        End If
    End Sub

    Protected Sub gv_PPER_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles gv_PPER.RowDataBound
        Dim TotalProducto As Double = 0
        Dim ProgramadoProducto As Double = 0
        Dim TransferidoProducto As Double = 0
        Dim EjacutadoProducto As Double = 0
        Dim PorcProducto As Double = 0
        Dim IAFG_Productos As Double = 0
        Dim vst As DataView
        Dim dt As DataTable
        If e.Row.RowType = DataControlRowType.DataRow Then
            Dim hfPPER As HiddenField = CType(e.Row.FindControl("hfPPER"), HiddenField)
            Dim lblPPER As Label = CType(e.Row.FindControl("lblPPER"), Label)
            ViewState("PPER") = lblPPER.Text
            Select Case hfPPER.Value
                Case "PPE-0001"
                    e.Row.BackColor = Drawing.Color.FromArgb(146, 208, 80)
                Case "PPE-0002"
                    e.Row.BackColor = Drawing.Color.FromArgb(204, 192, 218)
                Case "PPE-0003"
                    e.Row.BackColor = Drawing.Color.FromArgb(183, 222, 232)
            End Select

            vst = New DataView(ViewState("Data"), "PPER='" + hfPPER.Value.ToString + "'", "", DataViewRowState.CurrentRows)
            dt = New DataTable
            dt = vst.ToTable
            Dim gdv As GridView = e.Row.Cells(1).FindControl("gv_Detalle")
            gdv.DataSource = vst
            gdv.DataBind()
            vst = Nothing
            dt.Dispose()
        End If
    End Sub

    Public Sub RDB(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs)
        If e.Row.RowType = DataControlRowType.DataRow Then
            e.Row.BackColor = Drawing.Color.FromArgb(255, 255, 255)
        End If
    End Sub

    Protected Sub gv_Region_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles gv_Region.RowDataBound
        Dim vst As DataView
        Dim dt As DataTable
        If e.Row.RowType = DataControlRowType.DataRow Then
            Dim hfPPER As HiddenField = CType(e.Row.FindControl("hfPPER"), HiddenField)
            Dim lblPPER As Label = CType(e.Row.FindControl("lblPPER"), Label)
            ViewState("PPER") = lblPPER.Text
            Select Case hfPPER.Value
                Case "PPE-0001"
                    e.Row.BackColor = Drawing.Color.FromArgb(146, 208, 80)
                Case "PPE-0002"
                    e.Row.BackColor = Drawing.Color.FromArgb(204, 192, 218)
                Case "PPE-0003"
                    e.Row.BackColor = Drawing.Color.FromArgb(183, 222, 232)
            End Select

            vst = New DataView(ViewState("Data2"), "PPER='" + hfPPER.Value.ToString + "'", "", DataViewRowState.CurrentRows)
            dt = New DataTable
            dt = vst.ToTable
            Dim gdv As GridView = e.Row.Cells(1).FindControl("gv_Detalle")
            gdv.DataSource = vst
            gdv.DataBind()
            vst = Nothing
            dt.Dispose()
        End If
    End Sub

    Public Sub RDB2(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs)
        If e.Row.RowType = DataControlRowType.DataRow Then
            e.Row.BackColor = Drawing.Color.FromArgb(255, 255, 255)
        End If
    End Sub

End Class
